﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Acoris.Parser
{
    using System.Collections;
    using Acoris.Foundation;

    /// <summary>
    /// 
    /// </summary>
    public sealed class StateStack<TokenType> : IStack<StateFrame<TokenType>>
    {
        Stack< StateFrame<TokenType>> _stack;

        public StateStack()
        {
            _stack = new Stack<StateFrame<TokenType>>();
        }

        /// <summary>
        /// 
        /// </summary>
        public void Clear() => _stack.Clear();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Contains(StateFrame<TokenType> item) => _stack.Contains(item);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        /// <param name="index"></param>
        public void CopyTo(StateFrame<TokenType>[] array, int index) => _stack.CopyTo(array, index);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IEnumerator<StateFrame<TokenType>> GetEnumerator() => _stack.GetEnumerator();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public StateFrame<TokenType> Peek() => _stack.Peek();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public StateFrame<TokenType> Pop() => _stack.Pop();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        public void Push(StateFrame<TokenType> item) => _stack.Push(item);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IEnumerator IEnumerable.GetEnumerator() => _stack.GetEnumerator();

        /// <summary>
        /// 
        /// </summary>
        public int Count { get => _stack.Count; }

        /// <summary>
        /// 
        /// </summary>
        public bool Empty {
            get {
                return _stack.Count == 0;
            }
        }
    }
}
